﻿using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.WebAPI.Application.Command.PurchaseFormModelCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.PurchaseFormModelCommandHandler
{
	/// <summary>
	/// 获取采购列表
	/// </summary>
	public class GetPurchaseFormsCommandHandler : IRequestHandler<GetPurchaseFormsCommand, Results<PageOutput<PurchaseformmodelOutOut>>>
	{
		private readonly IPurchaseFormModelService _purchaseFormModelService;
		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="purchaseFormModelService"></param>
		public GetPurchaseFormsCommandHandler(IPurchaseFormModelService purchaseFormModelService)
		{
			_purchaseFormModelService = purchaseFormModelService;
		}
		/// <summary>
		/// 获取采购列表
		/// </summary>
		public async Task<Results<PageOutput<PurchaseformmodelOutOut>>> Handle(GetPurchaseFormsCommand request, CancellationToken cancellationToken)
		{
			var list = await _purchaseFormModelService.GetPurchaseForms(request.input);
			return Results<PageOutput<PurchaseformmodelOutOut>>.DataResult(list);
		}
	}
}
